<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="viewport"
		  content="width=device-width, initial-scale=1.0 ,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

	<title>结算页面</title>

	<link href="/static/home/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"/>

	<link href="/static/home/basic/css/demo.css" rel="stylesheet" type="text/css"/>
	<link href="/static/home/css/cartstyle.css" rel="stylesheet" type="text/css"/>

	<link href="/static/home/css/jsstyle.css" rel="stylesheet" type="text/css"/>

	<script type="text/javascript" src="/static/home/js/address.js"></script>

	<script src="/static/home/js/jquery-1.11.3.min.js"></script>

</head>

<body>

<!--顶部导航条 -->
<div class="am-container header">
	<ul class="message-r">
		<div class="topMessage home">
			<div class="menu-hd"><a href="/index/index/index" target="_top" class="h">商城首页</a></div>
		</div>
		<div class="topMessage my-shangcheng">
			<div class="menu-hd MyShangcheng"><a href="/index/person/index" target="_top"><i
				class="am-icon-user am-icon-fw"></i>个人中心</a></div>
		</div>
		<div class="topMessage mini-cart">
			<div class="menu-hd"><a id="mc-menu-hd" href="/index/person/shopcart" target="_top"><i
				class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum"
																					  class="h"></strong></a></div>
		</div>
		<div class="topMessage favorite">
			<div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a>
			</div>
		</div>
	</ul>
</div>

<!--悬浮搜索框-->

<div class="nav white">
	<div class="logo"><img src="/static/home/images/logo.png"/></div>
	<div class="logoBig">
		<li><img src="/static/home/images/logobig.png"/></li>
	</div>

	<div class="search-bar pr">
		<a name="index_none_header_sysc" href="#"></a>
		<form>
			<input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索" autocomplete="off">
			<input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
		</form>
	</div>
</div>

<form action="/index/person/order" method="post">
<div class="clear"></div>
<div class="concent">
	<!--地址 -->
	<div class="paycont">
		<div class="address">
			<h3>确认收货地址 </h3>
			<div class="control">
				<!--<div class="tc-btn createAddr theme-login am-btn am-btn-danger">使用新地址</div>-->
			</div>
			<div class="clear"></div>
			{if isset($receiveAddress)}
			<ul>
				<div class="per-border"></div>
				{foreach $receiveAddress as $val}
				{if $val['is_default'] == 1}
				<li class="user-addresslist defaultAddr address_default">

					<div class="address-left">
						<div class="user DefaultAddr">
<input type="hidden" class="receive_id" value="{$val['receive_id']}">
										<span class="buy-address-detail">   
                   <span class="buy-user">{$val['receive_name']} </span>
										<span class="buy-phone">{$val['receive_phone']|substr=0,3}****{$val['receive_phone']|substr=7}</span>
										</span>
						</div>
						<div class="default-address DefaultAddr">
							<span class="buy-line-title buy-line-title-type">收货地址：</span>
							<span class="buy--address-detail">
								  <span class="title">{$val['receive_address']}</span>
								<span class="street">{$val['detail_address']}</span>

							</span>
						</div>
						<ins class="deftip">默认地址</ins>
					</div>
					<div class="address-right">
						<a href="#">
							<span class="am-icon-angle-right am-icon-lg"></span></a>
					</div>
					<div class="clear"></div>

					<div class="new-addr-btn">
					</div>

				</li>
				{else}
				<div class="per-border"></div>
				<li class="user-addresslist" >
					<div class="address-left">
						<div class="user DefaultAddr">

										<span class="buy-address-detail">   
                   <span class="buy-user">{$val['receive_name']} </span>
										<span class="buy-phone">{$val['receive_phone']|substr=0,3}****{$val['receive_phone']|substr=7}</span>
										</span>
						</div>
						<div class="default-address DefaultAddr">
							<span class="buy-line-title buy-line-title-type">收货地址：</span>
							<span class="buy--address-detail">
											<span class="title">{$val['receive_address']}</span>
								<span class="street">{$val['detail_address']}</span>
<input type="hidden" class="receive_id" value="{$val['receive_id']}">
							</span>
						</div>
						<ins class="deftip hidden">默认地址</ins>
					</div>
					<div class="address-right">
						<span class="am-icon-angle-right am-icon-lg"></span>
					</div>
					<div class="clear"></div>

					<div class="new-addr-btn">
					</div>

				</li>
				{/if}
				{/foreach}
			</ul>
			{/if}
			<div class="clear"></div>
		</div>
		<!--物流 -->
		<div class="logistics">
			<h3>选择物流方式</h3>
			<ul class="op_express_delivery_hot">
				{if isset($trans)}
				{foreach $trans as $tran}
				<li data-value="{$tran['send_id']}" class="OP_LOG_BTN  " style="text-align: center"><img
					src="/{$tran['send_logo']}">{$tran['send_name']}

				</li>
				{/foreach}
				{/if}
			</ul>
		</div>
		<div class="clear"></div>

		<!--支付方式-->
		<div class="logistics">
			<h3>选择支付方式</h3>
			<ul class="pay-list">
				{if isset($payFunc)}
				{foreach $payFunc as $func}
				<li class="pay card" data-num="{$func['pay_id']}">
					<img src="/{$func['pay_logo']}"/>{$func['pay_name']}

				</li>
				{/foreach}
				{/if}
			</ul>
		</div>
		<input type="hidden" name="paymethod" value="" id="paymethod">
		<input type="hidden" name="postmethod" value="" id="postmethod">
		<div class="clear"></div>

		<!--订单 -->
		<div class="concent">
			<div id="payTable">
				<h3>确认订单信息</h3>
				<div class="cart-table-th">
					<div class="wp">

						<div class="th th-item">
							<div class="td-inner">商品信息</div>
						</div>
						<div class="th th-price">
							<div class="td-inner">单价</div>
						</div>
						<div class="th th-amount">
							<div class="td-inner">数量</div>
						</div>
						<div class="th th-sum">
							<div class="td-inner">金额</div>
						</div>
						<div class="th th-oplist">
							<div class="td-inner">配送方式</div>
						</div>

					</div>
				</div>
				<div class="clear"></div>
				{if isset($goods)}
				{foreach $goods as $val}
				<tr class="item-list">
					<div class="bundle  bundle-last">

						<div class="bundle-main">
							<ul class="item-content clearfix">
								<div class="pay-phone">
									<li class="td td-item">
										<div class="item-pic">
											<a href="#" class="J_MakePoint">
												<img src="/{$val['pic']}"
													 class="itempic J_ItemImg"></a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" class="item-title J_MakePoint" data-point="tbcart.8.11">{$val['name']}</a>
												<input name="name[{$val['goods_id']}]" type="hidden" value="{$val['name']}">
											</div>
										</div>
									</li>
									<li class="td td-info">
										<div class="item-props">
											<span class="sku-line">口味：{$val['taste']}</span>
											<input type="hidden" name="taste[{$val['goods_id']}]" value="{$val['taste']}">
										</div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<em class="J_Price price-now">{$val['price']}</em>
												<input type="hidden" name="price[{$val['goods_id']}]" value="{$val['price']}">
											</div>
										</div>
									</li>
								</div>
								<li class="td td-amount">
									<div class="amount-wrapper ">
										<div class="item-amount ">
											<span class="phone-title">购买数量</span>
											<div class="sl">
												<input class="min am-btn" name="" type="button" value="-"/>
												<input class="text_box" name="num[{$val['goods_id']}]" type="text" value="{$val['num']}"
													   style="width:30px;" readonly/>
												<input class="add am-btn" name="" type="button" value="+"/>
											</div>
										</div>
									</div>
								</li>
								<li class="td td-sum">
									<div class="td-inner">
										<em tabindex="0" class="J_ItemSum number">{$val['price']*$val['num']}</em>
									</div>
								</li>
								<li class="td td-oplist">
									<div class="td-inner">
										<span class="phone-title">配送方式</span>
										<div class="pay-logis">
											快递<b class="sys_item_freprice">10</b>元
										</div>
									</div>
								</li>

							</ul>
							<div class="clear"></div>

						</div>
					</div>
				</tr>
				{/foreach}
				{/if}
<!--直接提交订单的情况				-->
				{if isset($single)}
				<tr class="item-list">
					<div class="bundle  bundle-last">

						<div class="bundle-main">
							<ul class="item-content clearfix">
								<div class="pay-phone">
									<li class="td td-item">
										<div class="item-pic">
											<a href="#" class="J_MakePoint">
												<img src="/{$single['big']}"
													 class="itempic J_ItemImg"></a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" class="item-title J_MakePoint" data-point="tbcart.8.11">{$single['good_name']}</a>
												<input name="name[{$single['shop_id']}]" type="hidden" value="{$single['good_name']}">
											</div>
										</div>
									</li>
									<li class="td td-info">
										<div class="item-props">
											<span class="sku-line">口味：{$single['taste']}</span>
											<input type="hidden" name="taste[{$single['shop_id']}]" value="{$single['taste']}">
										</div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<em class="J_Price price-now">{$single['shop_price']}</em>
												<input type="hidden" name="price[{$single['shop_id']}]" value="{$single['shop_price']}">
											</div>
										</div>
									</li>
								</div>
								<li class="td td-amount">
									<div class="amount-wrapper ">
										<div class="item-amount ">
											<span class="phone-title">购买数量</span>
											<div class="sl">
												<input class="min am-btn" name="" type="button" value="-"/>
												<input class="text_box" name="num[{$single['shop_id']}]" type="text" value="{$single['num']}"
													   style="width:30px;"/>
												<input class="add am-btn" name="" type="button" value="+"/>
											</div>
										</div>
									</div>
								</li>
								<li class="td td-sum">
									<div class="td-inner">
										<em tabindex="0" class="J_ItemSum number">{$single['shop_price']*$single['num']}</em>
									</div>
								</li>
								<li class="td td-oplist">
									<div class="td-inner">
										<span class="phone-title">配送方式</span>
										<div class="pay-logis">
											快递<b class="sys_item_freprice">10</b>元
										</div>
									</div>
								</li>

							</ul>
							<div class="clear"></div>

						</div>
					</div>
				</tr>
				{/if}
				<div class="clear"></div>
			</div>
		</div>


		<div class="clear"></div>
		<div class="pay-total">
			<!--留言-->
			<div class="order-extra">
				<div class="order-user-info">
					<div id="holyshit257" class="memo">
						<label>买家留言：</label>
						<input type="text" title="选填,对本次交易的说明（建议填写已经和卖家达成一致的说明）" placeholder="选填,建议填写和卖家达成一致的说明"
							   class="memo-input J_MakePoint c2c-text-default memo-close" name="message">
						<div class="msg hidden J-msg">
							<p class="error">最多输入500个字符</p>
						</div>
					</div>
				</div>

			</div>
			<!--优惠券 -->
			<!--<div class="buy-agio">
				<li class="td td-coupon">

					<span class="coupon-title">优惠券</span>
					<select data-am-selected>
						<option value="a">
							<div class="c-price">
								<strong>￥8</strong>
							</div>
							<div class="c-limit">
								【消费满95元可用】
							</div>
						</option>
						<option value="b" selected>
							<div class="c-price">
								<strong>￥3</strong>
							</div>
							<div class="c-limit">
								【无使用门槛】
							</div>
						</option>
					</select>
				</li>

				<li class="td td-bonus">

					<span class="bonus-title">红包</span>
					<select data-am-selected>
						<option value="a">
							<div class="item-info">
								¥50.00<span>元</span>
							</div>
							<div class="item-remainderprice">
								<span>还剩</span>10.40<span>元</span>
							</div>
						</option>
						<option value="b" selected>
							<div class="item-info">
								¥50.00<span>元</span>
							</div>
							<div class="item-remainderprice">
								<span>还剩</span>50.00<span>元</span>
							</div>
						</option>
					</select>

				</li>

			</div>-->
			<div class="clear"></div>
		</div>
		<!--含运费小计 -->
		<div class="buy-point-discharge ">
			<p class="price g_price ">
				合计（含运费） <span>¥</span><em class="pay-sum" id="priceAll">244.00</em>
			</p>
		</div>

		<!--信息 -->
		<div class="order-go clearfix">
			<div class="pay-confirm clearfix">
				<div class="box">
					<div tabindex="0" id="holyshit267" class="realPay"><em class="t">实付款：</em>
						<span class="price g_price ">
                                    <span>¥</span> <em class="style-large-bold-red " id="J_ActualFee">244.00</em>
											</span>
					</div>
<input type="hidden" name="totalPrice" value="" id="totalPrice">
					<div id="holyshit268" class="pay-address">
						<p class="buy-footer-address">
							<span class="buy-line-title buy-line-title-type">寄送至：</span>
							<span class="buy--address-detail" id="address">
								<input id="addresshidden" name="address" value="" type="hidden">

							</span>
						</p>
						<p class="buy-footer-address">
							<span class="buy-line-title">收货人：</span>
							<span class="buy-address-detail">
                                         <span class="buy-user" id="aidi"> </span>
												<span class="buy-phone" id="aidiphone"></span>
												</span>
							<input id="ai_di" type="hidden" name="user" value="">
						</p>
					</div>
				</div>

				<div id="holyshit269" class="submitOrder">
					<div class="go-btn-wrap">
						<input type="button" value="提交订单" id="J_Go" href="#" class="btn-go" tabindex="0" title="点击此按钮，提交订单" style="float: right">
					</div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
	</div>

	<div class="clear"></div>
</div>
</div>
</form>

<div class="footer">
	<div class="footer-hd">
		<p>
			<a href="#">恒望科技</a>
			<b>|</b>
			<a href="/index/index/index">商城首页</a>
			<b>|</b>
			<a href="#">支付宝</a>
			<b>|</b>
			<a href="#">物流</a>
		</p>
	</div>
	<div class="footer-bd">
		<p>
			<a href="#">关于恒望</a>
			<a href="#">合作伙伴</a>
			<a href="#">联系我们</a>
			<a href="#">网站地图</a>
			<em>© 2015-2025 Hengwang.com 版权所有</em>
		</p>
	</div>
</div>
</div>
<!--<div class="theme-popover-mask"></div>
<div class="theme-popover">

	&lt;!&ndash;标题 &ndash;&gt;
	<div class="am-cf am-padding">
		<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> /
			<small>Add address</small>
		</div>
	</div>
	<hr/>

	<div class="am-u-md-12">
		<form class="am-form am-form-horizontal">

			<div class="am-form-group">
				<label for="user-name" class="am-form-label">收货人</label>
				<div class="am-form-content">
					<input type="text" id="user-name" placeholder="收货人">
				</div>
			</div>

			<div class="am-form-group">
				<label for="user-phone" class="am-form-label">手机号码</label>
				<div class="am-form-content">
					<input id="user-phone" placeholder="手机号必填" type="email">
				</div>
			</div>

			<div class="am-form-group">
				<label for="user-phone" class="am-form-label">所在地</label>
				<div class="am-form-content address">
					<select data-am-selected>
						<option value="a">浙江省</option>
						<option value="b">湖北省</option>
					</select>
					<select data-am-selected>
						<option value="a">温州市</option>
						<option value="b">武汉市</option>
					</select>
					<select data-am-selected>
						<option value="a">瑞安区</option>
						<option value="b">洪山区</option>
					</select>
				</div>
			</div>

			<div class="am-form-group">
				<label for="user-intro" class="am-form-label">详细地址</label>
				<div class="am-form-content">
					<textarea class="" rows="3" id="user-intro" placeholder="输入详细地址"></textarea>
					<small>100字以内写出你的详细地址...</small>
				</div>
			</div>

			<div class="am-form-group theme-poptit">
				<div class="am-u-sm-9 am-u-sm-push-3">
					<div class="am-btn am-btn-danger">保存</div>
					<div class="am-btn am-btn-danger close">取消</div>
				</div>
			</div>
		</form>
	</div>

</div>

<div class="clear"></div>-->
</body>
<script>
    $(function () {
        //页面加载时获取总价
        var allPrice = null;
        $('.J_ItemSum').each(function () {
            allPrice = accAdd(allPrice, 10);
            allPrice = accAdd(parseFloat($(this).text()), allPrice);
        });
        $('#J_ActualFee').text(allPrice);
        $('#priceAll').text(allPrice);
        $('#totalPrice').val(allPrice);

        //页面加载显示默认收件人信息
        $('#address').text($('.address_default').find('.buy--address-detail').text());//

        $('#aidi').text($('.address_default').find('.buy-user').text());
        $('#ai_di').val($('.address_default').find('.receive_id').val());


        $('#aidiphone').text($('.address_default').find('.buy-phone').text());


        //减号功能
        $('.min').click(function () {
            if ($(this).next().val() >= 1) {
                var sumPrice = $(this).parent().parent().parent().parent().next().find('.number').text();
                var onePiece = $(this).parent().parent().parent().parent().prev().find('.J_Price').text();
                var subPrice = accSub(sumPrice, onePiece);
                $(this).parent().parent().parent().parent().next().find('.number').text(subPrice);

                allPrice = $('#priceAll').text();
                var allNow = accSub(allPrice, onePiece);
                $('#J_ActualFee').text(allNow);
                $('#priceAll').text(allNow);
                $('#totalPrice').val(allNow);
            }
        });

        //加号功能
        $('.add').click(function () {
            var sumPrice = $(this).parent().parent().parent().parent().next().find('.number').text();
            var onePiece = $(this).parent().parent().parent().parent().prev().find('.J_Price').text();
            var subPrice = accAdd(sumPrice, onePiece);
            $(this).parent().parent().parent().parent().next().find('.number').text(subPrice);

            allPrice = $('#priceAll').text();
            var allNow = accAdd(allPrice, onePiece);
            $('#J_ActualFee').text(allNow);
            $('#priceAll').text(allNow);
            $('#totalPrice').val(allNow);
        });

        //地址点击
        $('li').click(function () {
            $('#address').text($(this).find('.buy--address-detail').text());

            $('#ai_di').val($(this).find('.receive_id').val());

            $('#aidi').text($(this).find('.buy-user').text());

            $('#aidiphone').text($(this).find('.buy-phone').text());


        });

        //物流邮寄方式的点击事件
        var postFlag = false;

        $('.OP_LOG_BTN').click(function () {
            $('#postmethod').val($(this).attr('data-value'));
            postFlag = true;
        });

        //支付方式的点击事件
        var wayFlag = false;

        $('.card').click(function () {
            wayFlag = true;
            $('#paymethod').val($(this).attr('data-num'));
        });

        //提交表单
		var addressFlag = false;
		var priceFlag = true;
		$('#J_Go').click(function () {
            if ($('#priceAll').text() > 30 ){
                priceFlag = true;
			} else {
                priceFlag = false;
			}

			if ($('#address').text() == '') {
                addressFlag = false;
			} else {
                addressFlag = true;
			}

			if (addressFlag && priceFlag && wayFlag && postFlag) {
                $(this).attr('type', 'submit');
			} else {
                alert('请检查确认信息');
			}

        });


        //精确的减法
        function accSub(arg1, arg2) {
            if (isNaN(arg1)) {
                arg1 = 0;
            }
            if (isNaN(arg2)) {
                arg2 = 0;
            }
            arg1 = Number(arg1);
            arg2 = Number(arg2);

            var r1, r2, m, n;
            try {
                r1 = arg1.toString().split(".")[1].length;
            }
            catch (e) {
                r1 = 0;
            }
            try {
                r2 = arg2.toString().split(".")[1].length;
            }
            catch (e) {
                r2 = 0;
            }
            m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度
            n = (r1 >= r2) ? r1 : r2;
            return ((arg1 * m - arg2 * m) / m).toFixed(n);
        }

        // 给Number类型增加一个mul方法，调用起来更加方便。
        Number.prototype.sub = function (arg) {
            return accSub(this, arg);
        };

        //精确的加法
        function accAdd(arg1, arg2) {
            if (isNaN(arg1)) {
                arg1 = 0;
            }
            if (isNaN(arg2)) {
                arg2 = 0;
            }
            arg1 = Number(arg1);
            arg2 = Number(arg2);
            var r1, r2, m, c;
            try {
                r1 = arg1.toString().split(".")[1].length;
            }
            catch (e) {
                r1 = 0;
            }
            try {
                r2 = arg2.toString().split(".")[1].length;
            }
            catch (e) {
                r2 = 0;
            }
            c = Math.abs(r1 - r2);
            m = Math.pow(10, Math.max(r1, r2));
            if (c > 0) {
                var cm = Math.pow(10, c);
                if (r1 > r2) {
                    arg1 = Number(arg1.toString().replace(".", ""));
                    arg2 = Number(arg2.toString().replace(".", "")) * cm;
                } else {
                    arg1 = Number(arg1.toString().replace(".", "")) * cm;
                    arg2 = Number(arg2.toString().replace(".", ""));
                }
            } else {
                arg1 = Number(arg1.toString().replace(".", ""));
                arg2 = Number(arg2.toString().replace(".", ""));
            }
            return (arg1 + arg2) / m;
        }

        //乘法...
        function accMul(arg1, arg2) {
            if (isNaN(arg1)) {
                arg1 = 0;
            }
            if (isNaN(arg2)) {
                arg2 = 0;
            }
            arg1 = Number(arg1);
            arg2 = Number(arg2);

            var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
            try {
                m += s1.split(".")[1].length;
            }
            catch (e) {
            }
            try {
                m += s2.split(".")[1].length;
            }
            catch (e) {
            }
            return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
        }
    });
</script>
</html>